<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Sistema de Cadastro</title>
        <link rel="stylesheet" href="menu.css" type="text/css" />
    </h:head>
    <h:body>
        <f:view contentType="text/html">
            <ui:composition template="template.xhtml">
                <ui:define name="titulo">Sistema de Cadastro</ui:define>

                <ui:define name="body">




                    <br/><br/><br/><br/>
                    <p:growl id="growl" showDetail="true" life="3000" />
                    <h:form prependId="false" id="eventolist">

                        <p:dataTable  var="item" value="#{eventoController.todos}" style="width:870px; height: 380px" paginator="true" rows="6" >
                            <f:facet name="header">
                                Eventos
                                <p:commandButton update="displayad" oncomplete="eventoAd.show()"
                                                 title="Adicionar"          image="ui-icon ui-icon-plusthick"

                                                 />

                            </f:facet>
                            <p:column  filterBy="#{item.nome}">
                                <f:facet name="header">
                                    <h:outputText value="Nome" />
                                </f:facet>
                                <h:outputText value="#{item.nome}" />
                            </p:column>
                            <p:column  filterBy="#{item.local}">
                                <f:facet name="header">
                                    <h:outputText value="Local" />
                                </f:facet>
                                <h:outputText value="#{item.local}" />
                            </p:column>
                            <p:column  filterBy="#{item.descricao}">
                                <f:facet name="header">
                                    <h:outputText value="Descrição" />
                                </f:facet>
                                <h:outputText value="#{item.descricao}" />
                            </p:column>
                            <p:column

                                >
                                <f:facet name="header">
                                    <h:outputText value="Data" />
                                </f:facet>
                                <h:outputText value="#{item.data}" >
                                    <f:convertDateTime pattern="dd/MM/yyyy"/>
                                </h:outputText>
                            </p:column>
                            <p:column style="width:32px">
                                <p:commandButton update="display3" oncomplete="eventoEx.show()"
                                                 title="Excluir"          image="ui-icon ui-icon-trash"

                                                 >
                                    <f:setPropertyActionListener value="#{item}"
                                                                 target="#{eventoController.bean}" />
                                </p:commandButton>
                                <p:commandButton update="displayed" oncomplete="eventoEd.show()"
                                                 title="Editar"          image="ui-icon ui-icon-pencil"

                                                 >
                                    <f:setPropertyActionListener value="#{item}"
                                                                 target="#{eventoController.bean}" />
                                </p:commandButton>
                            </p:column>
                        </p:dataTable>
                        <!-- ************************************************************** Dialogos-->



                    </h:form>
                    <h:form prependId="false">


                        <p:dialog header="Excluir Evento" widgetVar="eventoEx" resizable="false"
                                  height="170" width="350" showEffect="explode" hideEffect="explode" >

                            <h:panelGrid id="display3" columns="2" cellpadding="4">

                                <h:outputText value="Deseja Excluir ?" />
                                <h:outputText value="#{eventoController.bean.nome}" />
                                <p:commandButton actionListener="#{eventoController.excluir}" oncomplete="eventoEx.hide()"
                                                 value="ok" image="ui-icon ui-icon-trash" update="eventolist"             />

                            </h:panelGrid>
                        </p:dialog>
                    </h:form>
                    <h:form prependId="false">
                        <p:dialog  header="Cadastro de Evento" width="600"
                                   widgetVar="eventoAd" resizable="false"
                                   showEffect="explode" hideEffect="explode"
                                   id="insEvento"
                                   >
                            <h:panelGrid id="displayad" columns="2" cellpadding="6">

                                <h:outputLabel value="Nome:    "  />
                                
                                <p:inputText value="#{eventoController.bean.nome}"
                                             required="true"   requiredMessage=" campo nome obrigatório"/>


                                <h:outputLabel value="Local:    "  >
                                </h:outputLabel>
                                <p:inputText value="#{eventoController.bean.local}"
                                             required="true"  requiredMessage=" campo Local obrigatório"/>

                                <h:outputLabel value="Data:    " />

                                <p:calendar value="#{eventoController.bean.data}" required="true" showOn="button"
                                            requiredMessage="Data obrigatório"
                                            >
                                    <f:convertDateTime pattern="dd/MM/yyyy"/>
                                </p:calendar>




                                <h:outputLabel value="Descrição:    "  for="descricao" />


                                <h:inputTextarea value="#{eventoController.bean.descricao}" lang="45" label="descricao"
                                                 id="descricao"          required="true"  requiredMessage=" campo descricao obrigatório"/>

                                <p:commandButton actionListener="#{eventoController.salvar}" oncomplete="eventoAd.hide()"
                                                 value="Salvar" image="ui-icon ui-icon-trash" update="growl,eventolist"             />

                            </h:panelGrid>
                            <p:messages/>
                        </p:dialog>





                    </h:form>
                    <h:form prependId="false">

                        <p:dialog  header="Editar Evento" width="600"
                                   widgetVar="eventoEd" resizable="false"
                                   showEffect="explode" hideEffect="explode"
                                   id="edEvento"
                                   >
                            <h:panelGrid id="displayed" columns="2" cellpadding="6">

                                <h:outputLabel value="Nome:    "  >
                                </h:outputLabel>
                                <p:inputText value="#{eventoController.bean.nome}"
                                             required="true"  requiredMessage=" campo nome obrigatório"/>


                                <h:outputLabel value="Local:    "  >
                                </h:outputLabel>
                                <p:inputText value="#{eventoController.bean.local}"
                                             required="true"  requiredMessage=" campo Local obrigatório"/>

                                <h:outputLabel value="Data:    " />

                                <p:calendar value="#{eventoController.bean.data}" required="true" showOn="button"
                                            requiredMessage="Data obrigatório"
                                            >
                                    <f:convertDateTime pattern="dd/MM/yyyy"/>
                                </p:calendar>




                                <h:outputLabel value="Descrição:    "  for="descricao" />


                                <h:inputTextarea value="#{eventoController.bean.descricao}" lang="45" label="descricao"
                                                 required="true"  requiredMessage=" Descrição do evento obrigatório"/>

                                <p:commandButton actionListener="#{eventoController.update}" oncomplete="eventoEd.hide()"
                                                 value="Editar" image="ui-icon ui-icon-pencil" update="growl,eventolist"             />

                            </h:panelGrid>
                            <p:messages/>
                        </p:dialog>




                    </h:form>

                </ui:define></ui:composition>
        </f:view>
    </h:body>
</html>

